#ifndef __LIGHT_GROUP_H__
#define __LIGHT_GROUP_H__

#include <cstdint>
#include "light_item.h"

class LightGroup
{
public:
    LightGroup(uint32_t pulse_frequency) : __pulse_frequency(pulse_frequency)
    {
    }

    ~LightGroup()
    {
    }

    /// @brief 脉冲计数器
    /// @note 每收到一个脉冲，计数器加1
    /// @note 计数器溢出时，计数器清零
    void update_pulse_counter()
    {
        ++__pulse_counter;
    }

    /// @brief 获取脉冲计数器
    /// @return 脉冲计数器
    uint32_t get_pulse_counter() const
    {
        return __pulse_counter;
    }

    /// @brief 获取脉冲频率
    /// @return 脉冲频率
    uint32_t get_pulse_frequency() const
    {
        return __pulse_frequency;
    }

    /// @brief 获取脉冲周期
    /// @return 脉冲周期
    uint32_t get_pulse_period() const
    {
        return 1000 / __pulse_frequency;
    }

private:
    const uint32_t __pulse_frequency;
    volatile uint32_t __pulse_counter{0};
};

#endif // __LIGHT_GROUP_H__